]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
popupMenu: Add the ability to block sending events to the source actor
authorOwen W. Taylor <otaylor@fishsoup.net>
Tue, 22 Mar 2011 14:29:32 +0000 (10:29 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Tue, 22 Mar 2011 16:38:25 +0000 (12:38 -0400)
It can be useful to avoid sending enter/leave events to the source actor
of a menu: this would be the case when the source actor isn't a menu item
that should participate in menu navigation but rather is some object
(like an app icon) that we want to indicate corresponds to the menu.

https://bugzilla.gnome.org/show_bug.cgi?id=642871

js/ui/popupMenu.js

index 887fb41f246d75f7739a9932bddfb5119ca0a0bd..7531f77d8eb6a2faa7f62f437ea512a08389244f 100644 (file)
@@ -724,6 +724,11 @@ PopupMenuBase.prototype = {
         }
 
         this.isOpen = false;
+
+        // If set, we don't send events (including crossing events) to the source actor
+        // for the menu which causes its prelight state to freeze
+        this.blockSourceEvents = false;
+
         this._activeMenuItem = null;
     },
 
@@ -1331,14 +1336,20 @@ PopupMenuManager.prototype = {
         return this._activeMenuContains(event.get_source());
     },
 
-    _eventIsOnAnyMenuSource: function(event) {
+    _shouldBlockEvent: function(event) {
         let src = event.get_source();
+
+        if (this._activeMenu != null && this._activeMenu.actor.contains(src))
+            return false;
+
         for (let i = 0; i < this._menus.length; i++) {
             let menu = this._menus[i].menu;
-            if (menu.sourceActor && menu.sourceActor.contains(src))
-                return true;
+            if (menu.sourceActor && !menu.blockSourceEvents && menu.sourceActor.contains(src)) {
+                return false;
+            }
         }
-        return false;
+
+        return true;
     },
 
     _findMenu: function(item) {
@@ -1370,7 +1381,7 @@ PopupMenuManager.prototype = {
         } else if (eventType == Clutter.EventType.BUTTON_PRESS && !activeMenuContains) {
             this._closeMenu();
             return true;
-        } else if (activeMenuContains || this._eventIsOnAnyMenuSource(event)) {
+        } else if (!this._shouldBlockEvent(event)) {
             return false;
         }